using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameStateManagement;
using Microsoft.Xna.Framework;

namespace PiratesOfBermuda
{
    class GameOverScreen : MenuScreen
    {
        GameScreen gameplayScreen;
        bool isMultiPlayers;

        public GameOverScreen(GameScreen gameplayScreen, bool isMultiPlayers)
            : base(String.Empty)
        {
            IsPopup = true;
            this.gameplayScreen = gameplayScreen;
            this.isMultiPlayers = isMultiPlayers;

            MenuEntry startNewGame = new MenuEntry("Start New Game");
            MenuEntry exitMenuEntry = new MenuEntry("Quit");

            startNewGame.Selected += startNewGame_Selected;
            exitMenuEntry.Selected += exitMenuEntry_Selected;

            MenuEntries.Add(startNewGame);
            MenuEntries.Add(exitMenuEntry);
        }

        protected override void UpdateMenuEntryLocations()
        {
            base.UpdateMenuEntryLocations();

            foreach (var entry in MenuEntries)
            {
                var position = entry.Position;

                position.Y += 60;

                entry.Position = position;
            }
        }

        void exitMenuEntry_Selected(object sender, EventArgs e)
        {
            ScreenManager.AddScreen(new MainMenuScreen());
            ExitScreen();
            gameplayScreen.ExitScreen();
        }

        void startNewGame_Selected(object sender, EventArgs e)
        {
            if (isMultiPlayers)
            {
                ScreenManager.AddScreen(new MultiPlayersMenuScreen());
            }
            else
            {
                ScreenManager.AddScreen(new SinglePlayerScreen());
            }
            ExitScreen();
            gameplayScreen.ExitScreen();
        }


    }
}
